﻿using DataAccessObjectLayer;
using ModelLayer;
using System.Collections.Generic;

namespace ControllerLayer
{
    public class PersonCtr : IPersonCtr
    {
        /// <summary>
        /// inserts a new customer to the database with information coming from a customer object
        /// </summary>
        /// <param name="customer">The customer.</param>
        /// <returns>The number of affected rows</returns>
        public int CreateCustomer(Customer customer)
        {
            var dbC = new DBCustomer();
            return dbC.InsertCustomer(customer);
        }

        /// <summary>
        /// Returns a single customer from a given id
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>Customer.</returns>
        public Customer GetCustomer(long id)
        {
            var dbC = new DBCustomer();
            return dbC.GetCustomer(id);
        }

        /// <summary>
        /// updates an existing customer in the database with information coming from a customer
        /// object
        /// </summary>
        /// <param name="customer">The customer.</param>
        /// <returns>The number of affected rows</returns>

        public int UpdateCustomer(Customer customer)
        {
            var dbC = new DBCustomer();
            return dbC.UpdateCustomer(customer);
        }

        /// <summary>
        /// Deletes a customer from the database
        /// </summary>
        /// <param name="customerId">The customer id.</param>
        /// <returns>The number of affected rows</returns>
        public int DeleteCustomer(long customerId)
        {
            var dbC = new DBCustomer();
            return dbC.DeleteCustomer(customerId);
        }

        /// <summary>
        /// gets a list containing all customers in the database
        /// </summary>
        /// <returns>List{Customer}.</returns>
        public List<Customer> GetAllCustomer()
        {
            var dbC = new DBCustomer();
            return dbC.GetAllCustomer();
        }
    }
}